package com.x.mvp.widget.ruler;

import android.graphics.Canvas;
import android.graphics.Paint;

/**
 * Created by H on 18/3/5.
 */

public class ScaleRander extends Rander {
    Paint forePan;
    Paint backPan;

    public ScaleRander(int foregoundColor, int backgoundColor, int split, int totalLength, int offset) {
        super(foregoundColor, backgoundColor, split, totalLength, offset);
    }

    @Override
    void init() {
        super.init();
        forePan = new Paint();
        forePan.setColor(foregoundColor);
        forePan.setStrokeWidth(2f);
        forePan.setAntiAlias(true);

        backPan = new Paint();
        backPan.setColor(backgoundColor);
        backPan.setStrokeWidth(2f);
        backPan.setAntiAlias(true);
    }

    @Override
    public void onDraw(Canvas canvas) {
        int w = canvas.getWidth();
        int h = canvas.getHeight();
        int[] fir = getFirstScale(w);
        canvas.drawLine(0, 0, w, 0, backPan);
        canvas.drawLine(0, h, w, h, backPan);
        for (int i = 0; i < w / split; i++) {
            if (fir[1] % 10 == 0) {
                canvas.drawLine(fir[0], 0, fir[0], 30, backPan);
            } else {
                canvas.drawLine(fir[0], 0, fir[0], 10, backPan);
            }
            fir[0] += split;
            fir[1]++;
        }

    }

}
